//
//  ByUIMineWelfareVC.m
//  chequanbao_ios
//
//  Created by mc on 2017/6/13.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByUIMineWelfareVC.h"

// vc
#import "ByUIMineWelfareOneVC.h"
#import "ByUIMineWelfareTwoVC.h"

@interface ByUIMineWelfareVC ()
@property (nonatomic, strong) UIScrollView *scroll;
@end

@implementation ByUIMineWelfareVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我的福利";
    [self addLeftBackBarButtonItem];
    [self createView];
}

- (UIScrollView *)scroll {
    
    if (!_scroll) {
        _scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64)];
        _scroll.showsVerticalScrollIndicator = NO;
        _scroll.bounces = NO;
        [self.view addSubview:_scroll];
    }
    return _scroll;
}

#pragma mark -- 创建视图
- (void)createView{

    // 福利驾到
    CGFloat width = SCREEN_WIDTH - 30*2;
    UIImageView *welfareImg = [[UIImageView alloc] initWithFrame:CGRectMake(30, 0, width, width / 1.6)];
    welfareImg.image = [UIImage imageNamed:@"mine_welfare"];
    [self.scroll addSubview:welfareImg];
    
//    // 注册会员
//    width = SCREEN_WIDTH - 30*2;
//    UIImageView *detailImg = [[UIImageView alloc] initWithFrame:CGRectMake(30, welfareImg.bottom + 20, width, width/6)];
//    detailImg.image = [UIImage imageNamed:@"mine_detail1"];
//    [self.scroll addSubview:detailImg];
//    detailImg.userInteractionEnabled = YES;
//    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
//    [detailImg addGestureRecognizer:tap];
//
//    // 大礼包
//    width = SCREEN_WIDTH - 10*2;
//    UIImageView *detailImg2 = [[UIImageView alloc] initWithFrame:CGRectMake(10, detailImg.bottom + 10, width, width/7)];
//    detailImg2.image = [UIImage imageNamed:@"mine_detail2"];
//    [self.scroll addSubview:detailImg2];
    
    
    //详情点击
    UIView *bgView = [[UIView alloc] init];
    bgView.backgroundColor = BY_BG_WHITHE;
    bgView.layer.cornerRadius = 4.0;
    [self.scroll addSubview:bgView];
    
    NSString *title = @"推荐亲朋好友消费均可获得源源不断的消费分红喔：（详情点击）";
    CGFloat height = [title getRectOfStringWithSize:CGSizeMake(SCREEN_WIDTH - 40, 10000) font:14].size.height;
    UILabel *titleLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, SCREEN_WIDTH - 40, height)];
    titleLabel1.numberOfLines = 0;
    titleLabel1.font = FONT(14);
    titleLabel1.text = title;
    titleLabel1.textColor = [UIColor whiteColor];
    [bgView addSubview:titleLabel1];
    
    
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(5, titleLabel1.bottom + 20, SCREEN_WIDTH - 30, 0.5)];
    line.backgroundColor = [UIColor lightGrayColor];
    [bgView addSubview:line];
    
    title = @"您将每年获得600元-3000元车险大礼包甚至车险可全免费：（详情点击）";
    height = [title getRectOfStringWithSize:CGSizeMake(SCREEN_WIDTH - 40, 10000) font:14].size.height;
    UILabel *titleLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(10, line.bottom + 20,SCREEN_WIDTH - 40, height)];
    titleLabel2.numberOfLines = 0;
    titleLabel2.text = title;
    titleLabel2.font = FONT(14);
    titleLabel2.textColor = [UIColor whiteColor];
    [bgView addSubview:titleLabel2];
    bgView.frame = CGRectMake(10, welfareImg.bottom + 20, SCREEN_WIDTH - 20, titleLabel2.bottom + 20);
    
    // 解释权
    width = SCREEN_WIDTH - 5*2;
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, bgView.bottom + 40, width, 20)];
    label.text = @"本活动所有解释权归大连掌握信息科技有限公司所有";
    label.textColor = [UIColor whiteColor];
    label.font = FONT(14);
    label.textAlignment = NSTextAlignmentCenter;
    label.adjustsFontSizeToFitWidth = YES;
    [self.scroll addSubview:label];
    
    self.scroll.contentSize = CGSizeMake(0, label.bottom + 20);
    
    
    // 添加事件
    titleLabel1.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
    [titleLabel1 addGestureRecognizer:tap];

    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap2Action)];
    titleLabel2.userInteractionEnabled = YES;
    [titleLabel2 addGestureRecognizer:tap2];


}

#pragma mark -- 点击事件
- (void)tapAction{
    ByUIMineWelfareOneVC *vc = [[ByUIMineWelfareOneVC alloc] init];
    [self by_normalPush:vc hasNavi:YES];
}

- (void)tap2Action{
    
    ByUIMineWelfareTwoVC *vc = [[ByUIMineWelfareTwoVC alloc] initWithTitle:@"我的福利" imageName:@"mine_ziyuan" content1:@"您的车险可以免费哦" content2:@"如您的汽车保费每年都应交5000元左右，其中交强险960元、车船税350元、商业保险3690元，下载有车有保app或者关注公众号购买车险即可节省约商业保险（3690元Ｘ25％中介佣金）900元，只需缴纳4100元；同时您利用有车有保app或者公众号在任何联盟商家消费，在享受优惠折扣的同时额外又获得消费分红并可不断累计，如您家庭月消费5000元Ｘ5％消费分红Ｘ12=3000元/年可抵扣车险，您购买车险时只需要1100元即可，消费越多分红越多，从而帮助您的车险可少花钱。" content3:@"会员幸福分享" content4:@"1：2017年11月王先生（车牌号辽B803HF）按照自身需求购买了商业险，系统报价1988.08元，掌握科技帮助王先生节省中介佣金371.75（仅限商业险），实际上只花了1616.33元就获得了第二年的保障。\n2：2017年11月张女士（车牌号辽B1580L）按照自身需求购买了商业险，系统报价2731.78元，掌握科技帮助王先生节省中介佣金510.8（仅限商业险），实际上只花了2220.98元就获得了第二年的保障。" content5:@"注明：此上会员案例分享仅限于大连地区的车险优惠折扣，全国其他地区推广，会根据当地合作保险公司实际情况而调整到最高优惠折扣，让利于会员。"];
    [self by_normalPush:vc hasNavi:YES];

}


@end
